<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>私有云平台</title>
	<meta charset="utf-8"/>
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/public/bootstrap/css/bootstrap.css"/>
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/public/bootstrap/css/bootstrap-responsive.css"/>
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/css/jquery-ui-redmond/jquery-ui-1.8.21.custom.css">
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/css/global2.css">
	<script type="text/javascript" src="/EECloud/resource/jquery/jquery.js"></script>
    <script src="/EECloud/resource/public/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/EECloud/resource/jquery/jquery-ui-1.8.22.custom.min.js"></script>
    <script type="text/javascript">
    	$(document).ready(function(){
    		var menu_title = '<?=$menuTitle;?>';
    		$("#" + menu_title).addClass('active');

    	});
    </script>
	<style type="text/css">
		html,body{
			background-color: #EEE;
			height: 100%;
			width: 100%;
			margin: 0;
			padding: 0;
		}

		.list-header{
			margin: 10px 60px 10px 55px;
			font-size: 13px;
		}
		.list-item-head{
			border: 1px solid #e5e5e5;
			clear: both;
			width: 90%;
			float: left;
			margin-left: 55px;
			line-height: 36px;
			background-color: #EEE;
			/*color: #e5e5e5;*/
		}

		.list-item{
			border-bottom: 1px solid #e5e5e5;
			clear: both;
			width: 90%;
			float: left;
			margin-left: 55px;
			line-height: 36px;
		}

		.chk-head{
			float: left;
			margin-left: 10px;
		}

		.chk{
			float: left;
			margin-left: 11px;
			/*margin-top: 5px;*/
		}

		.col{
			float: left;

		}
		
		.c2{
			border-left: 1px solid #e5e5e5;
			border-right: 1px solid #e5e5e5;
			/*padding-left: 8px;*/
		}
		.c3{
			/*padding-left: 8px;*/
		}
		.hover{
			background-color:#eee;
		}
		.abc{
			/*background-color: black;*/
		}
		
		#container{
			/*position:absolute;left:0;right:0;top:0;bottom:0;*/
			height: 91%;
		}

		.row-fluid{
			height: 100%;
		}
		.span2{
			height: 100%;
			background-color:white;
		}
		.span10{
			height: 100%;
			background-color:white;
		}
		.pagination_top{
			padding-bottom: 100px;
		}

	</style>
</head>
<body>
	<div class="container-fluid" style="min-width:1100px">
		<div class="navbar navbar-inverse">
			<div class="navbar-inner">
				<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
	              <span class="icon-bar"></span>
	              <span class="icon-bar"></span>
	              <span class="icon-bar"></span>
	            </button>
	            <a class="brand" href="#"><img src="/EECloud/resource/img/pLogo.jpg" style="width:35px;height:25px">私有云平台</a>
	            <ul class="nav">
	            	<li class=""><a href="/EECloud/index.php/index">首页</a></li>
	            	<li><a href="/EECloud/index.php/pcloud">公共云</a></li>
	            	<li class="dropdown">
	            		<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);">全部文件 <b class="caret"></b></a>
	            		<ul class="dropdown-menu">
	            			<li><a href="/EECloud/index.php/ring">全部文件</a></li>
	            			<li><a href="/EECloud/index.php/ring/files">文档</a></li>
	            			<li><a href="/EECloud/index.php/ring/images">图片</a></li>
	            			<li><a href="/EECloud/index.php/ring/vedios">视频</a></li>
	            			<li><a href="/EECloud/index.php/ring/music">音乐</a></li>
	            			<li><a href="/EECloud/index.php/ring/others">其他</a></li>
	            			<li class="divider"></li>
	            			<li><a href="/EECloud/index.php/ring/shares">我的分享</a></li>
	            			<li class="divider"></li>
	            			<li><a href="/EECloud/index.php/ring/recycleBin">我的回收站</a></li>
	            		</ul>
	            	</li>
	            </ul>
	            <ul class="nav" style="float:right;font-size:12px">
	            	<li>
	            		<form class="navbar-search">
						  <input type="text" class="search-query" placeholder="Search" value="" id="search_value">
						  <a class="btn btn-small" style="margin-right:20px;margin-left:10px" id="search"><i class="icon-search"></i> 搜索</a>
						</form>
	            	</li>
	            	<li><a href="/EECloud/index.php/userinfo"><i class="icon-user icon-white"></i> <?php echo $userName;?></a></li>
	            	<li><a href=""><i class="icon-envelope icon-white"></i> 通知</a></li>
	            	<li><a href="javascript:void(0);" id="returnIndex"><i class="icon-off icon-white"></i> 退出</a></li>
	            </ul>	
			</div>
		</div>
	</div>
	<div class="container-fluid" id="container">
		<div class="row-fluid">
			<div class="span2">
				<ul class="nav nav-list">
					<li class="nav-header" style="font-size:20px">全部文件</li>
					<li class="divider"></li>
					<li id="allMenu"><a href="/EECloud/index.php/ring"><i class="icon-list-alt"></i> 全部文件</a></li>
					<li id="filesMenu"><a href="/EECloud/index.php/ring/files"><i class="icon-file"></i> 文档</a></li>
					<li id="imagesMenu"><a href="/EECloud/index.php/ring/images"><i class="icon-picture"></i> 图片</a></li>
					<li id="vediosMenu"><a href="/EECloud/index.php/ring/vedios"><i class="icon-film"></i> 视频</a></li>
					<li id="musicMenu"><a href="/EECloud/index.php/ring/music"><i class="icon-music"></i> 音乐</a></li>
					<li id="othersMenu"><a href="/EECloud/index.php/ring/others"><i class="icon-th-list"></i> 其他</a></li>
					<li class="divider"></li>
					<li id="sharesMenu"><a href="/EECloud/index.php/ring/shares"><i class="icon-share"></i> 我的分享</a></li>
					<li><a href="/EECloud/index.php/publishres/allres"><i class="icon-eye-open"></i> 资源审核</a></li>
					<li class="divider"></li>
					<li id="recycleMenu"><a href="/EECloud/index.php/ring/recycleBin"><i class="icon-trash"></i> 我的回收站</a></li>
				</ul>
			</div>
				<div class="span10">
				<div class="row-fluid">
					<div class="span12" style="background-color:white;">
						<!-- <a href="" class="btn btn-primary">新建文件夹</a> -->
						<a href="javascript:void(0);" class="btn btn-primary" id="upload"><i class="icon-upload icon-white"></i> 文件上传</a>
						<a href="javascript:void(0);" class="btn btn-primary" id="downloadAll"><i class="icon-download-alt icon-white"></i> 文件下载</a>
						<!-- <a href="javascript:void(0);" class="btn btn-primary">文件发布</a> -->
						<a href="javascript:void(0);" class="btn btn-danger" id="deleteAll"><i class="icon-trash icon-white"></i> 删除</a>
					</div>
					<div class="span12 pagination_top" style="margin:0">
						<div>
							<span  id="abc" class="list-header" style="float:left">全部文件</span><span class="list-header" style="float:right">已加载<?=$resourcesNum;?>项</span>
						</div>
						<div class="list-item-head">
							<div class="chk-head" style="width:5%" ><input type="checkbox" style="margin:auto;visibility:hidden" id="chkHead"></div>
							<div class="col c1" style="width:55%">文件名</div>
							<div class="col c2" style="width:15%;text-align:center">大小</div>
							<div class="col c3" style="width:20%;text-align:center">上传时间</div>
						</div>
						<div id="display_resources">
							<?php if(!empty($records)) :?>
							<?php foreach ($records as $key => $val):?>
								<div class="list-item">
									<div class="chk" style="width:5%" name="chk"><input type="checkbox" style="margin:auto;cursor:default" name="chkItem" onclick="selectClick(this)"></div>
									<div class="col" style="width:45%"><a href="javascript:void(0);" title="<?=$val["resourceName"];?>"><?=$val["resourceName"];?></a></div>
									<div class="col" style="width:3%;visibility:hidden" name="action"><a href="javascript:void(0);" class="download"><i class="icon-download" title="下载"></i></a></div>
									<div class="col" style="width:3%;visibility:hidden" name="action"><a href="javascript:void(0);" class="share_res"><i class="icon-share" title="分享"></i></a></div>
									<div class="col" style="width:3%;visibility:hidden" name="action"><a href="javascript:void(0);" class="delteItem"><i class="icon-remove" title="删除"></i></a></div>
									<div class="col" style="width:15%;text-align:center;padding-left:10px"><?=$val['size'];?>K</div>
									<div class="col" style="width:20%;text-align:center"><?=$val['uploadTime'];?></div>
									<div class="col" style="visibility:hidden" name="rId" id="rId"><?=$val['id'];?></div>
								</div>
							<?php endforeach;?>
							<?php endif;?>
						</div>
						<!-- 文件上传弹出窗口 -->
						<div id="uploadBox" title="上传文件">
							<form id="uploadForm" action="/EECloud/index.php/ring/do_upload" enctype="multipart/form-data" method="post">
								<table>
									<tr>
										<td><input type="file"  name="userfile" size="20" id="userfile"></td>
										<input type="hidden" name='userName' value="<?=$userName?>">
										<!-- <input type="hidden" name="userId" value="<?=$userId?>"> -->
									</tr>
								</table>
							</form>
						</div>
						<!-- 文件删除窗口 -->
						<div id="deleteBox" title="">
							<div>确定删除？</div>
						</div>

						<div id="deleteAllBox" title="">
							<div>确定删除？</div>
						</div>

						<script type="text/javascript">

							function share_res(id){
								window.location.href ='/EECloud/index.php/publishres/main?id=' + id;
							}
 
							//resourceId里存入的是需要删除的文件的ID号
							var resourceId = [];
							//被删除项的ID
							var itemId = '';
							function selectClick(o){

				    			var idDiv = o.parentNode.parentNode.childNodes.item(15);

				    			// alert(idDiv);

				    			Array.prototype.indexOf = function(val) {
						            for (var i = 0; i < this.length; i++) {
						                if (this[i] == val) return i;
						            }
						            return -1;
						        };
						        
						        Array.prototype.remove = function(val) {
						            var index = this.indexOf(val);
						            if (index > -1) {
						                this.splice(index, 1);
						            }
						        };
				
				    			if(navigator.appName.indexOf('Explorer') > -1)  {
				    				if(o.checked){
				    					var action1 = o.parentNode.parentNode.childNodes.item(5);
				    					var action2 = o.parentNode.parentNode.childNodes.item(7);
				    					var action3 = o.parentNode.parentNode.childNodes.item(9);
				    					action1.style.visibility = "";
				    					action2.style.visibility = "";
				    					action3.style.visibility = "";
				    					resourceId.push(idDiv.innerHTML);
				    				}else{
				    					var action1 = o.parentNode.parentNode.childNodes.item(5);
				    					var action2 = o.parentNode.parentNode.childNodes.item(7);
				    					var action3 = o.parentNode.parentNode.childNodes.item(9);
				    					action1.style.visibility = 'hidden';
				    					action2.style.visibility = 'hidden';
				    					action3.style.visibility = 'hidden';
				    					resourceId.remove(idDiv.innerHTML);
				    				}    
				    			}else{
				    				if(o.checked){
				    					var action1 = o.parentNode.parentNode.childNodes.item(5);
				    					var action2 = o.parentNode.parentNode.childNodes.item(7);
				    					var action3 = o.parentNode.parentNode.childNodes.item(9);
				    					action1.style.visibility = "";
				    					action2.style.visibility = "";
				    					action3.style.visibility = "";
				    					resourceId.push(idDiv.textContent);
				    					// alert(resourceId);
				    				}else{
				    					var action1 = o.parentNode.parentNode.childNodes.item(5);
				    					var action2 = o.parentNode.parentNode.childNodes.item(7);
				    					var action3 = o.parentNode.parentNode.childNodes.item(9);
				    				
				    					action1.style.visibility = 'hidden';
				    					action2.style.visibility = 'hidden';
				    					action3.style.visibility = 'hidden';
				    					// var action =  $(this).parent().siblings("div[name='action']").css('height','1000');
				    					resourceId.remove(idDiv.textContent);
				    				} 
				    			} 
								
				    		}

							$("#uploadBox").dialog({
								autoOpen: false,
								height: 200,
								width: 400,
								modal: true,
								buttons: {
									"上传":function(){
										var filePath = $('input[type=file]').val();
										var fileName = filePath.replace(/.*(\/|\\)/,"");
										var fileText = filePath.substring(filePath.lastIndexOf("."),filePath.length);
										// alert(filePath);
										if($("#userfile").val() == ''){
											alert('请选择需要上传的文件');
										}else{
											$('#uploadForm').submit();
										}
										
									},
									"取消":function(){
										$(this).dialog('close');
									}
								}
							});

							$("#deleteBox").dialog({
								autoOpen: false,
								height: 150,
								width: 250,
								modal: true,
								buttons: {
									"确定":function(){
				    					window.location.href = '/EECloud/index.php/ring/drop_recycle?rId=' + itemId;
									},
									"取消":function(){
										$(this).dialog('close');
									}
								}
								
							});

							$("#deleteAllBox").dialog({
								autoOpen: false,
								height: 150,
								width: 250,
								modal: true,
								buttons: {
									"确定":function(){
										if(resourceId.length == 1){
											// alert(resourceId[0]);
											window.location.href = '/EECloud/index.php/ring/drop_recycle?rId=' + resourceId[0];
										}else{
											window.location.href = '/EECloud/index.php/ring/drop_all_recycle?resourceId=' + resourceId;
										}
										
									},
									"取消":function(){
										$(this).dialog('close');
									}
								}
							});

					    	$(document).ready(function(){

					     		//if(window.name!="hasLoad"){
								// 	location.reload();
								// 	window.name = "hasLoad";
								// }else{
								// 	window.name="";
								// }

					    		// var _height = window.screen.height-200;
					    		// $('#container').css('height',_height);
					   
					    		<?=$alert;?>

					    		$(function(){
					    			$('.list-item').mouseover(function(){
					    				$(this).addClass("hover").siblings().removeClass("hover");
					    			});
					    		})

					    		$(function(){
					    			$('.list-item').mouseout(function(){
					    				$(this).removeClass("hover");
					    			});
					    		})

					    		$("#chkHead").bind('click',function(){
					    			if(document.getElementById('chkHead').checked){
					    				$("[name = chkItem]:checkbox").attr("checked",true);
					    			}else{
					    				$("[name = chkItem]:checkbox").attr("checked",false);
					    			}
					    				
					    		});

					    		$("#upload").click(function(){
	    							$("#uploadBox").dialog("open");
	    						});

					    		$("#deleteAll").click(function(){
					    			if(resourceId == ''){
					    				alert('请选择您想删除的文件！');
					    			}else{
					    				$("#deleteAllBox").dialog("open");
					    			}
					    			
					    		});

	    						$(".delteItem").click(function(){
	    							var index = $(this).parent().parent().children("div #rId").text();
	    							// alert(index);
	    							itemId = index;
	    							$("#deleteBox").dialog("open");
	    						});

	    						$("#downloadAll").click(function(){
	    							if(resourceId == ''){
	    								alert("请选择您想下载的文件！");
	    							}else if(resourceId.length == 1){
	    								window.location.href = '/EECloud/index.php/ring/do_download?rId=' + resourceId[0];
	    							}else{
	    								window.location.href = '/EECloud/index.php/ring/tozip?resourceId=' + resourceId;
	    							}
	    						});

					    		$(".download").click(function(){
					    			var index = $(this).parent().parent().children("div #rId").text();
					    			// alert(index);
					    			itemId = index;
					    			window.location.href = '/EECloud/index.php/ring/do_download?rId=' + itemId;
					    		});

					    		$("#returnIndex").click(function(){
					    			window.location.href = '/EECloud/index.php/login/logout';
					    		});

					    		$('.share_res').click(function(){
					    			var index = $(this).parent().parent().children("div #rId").text();
					    			itemId = index;
					    			// alert(itemId);
					    			$.post('/EECloud/index.php/publishres/ajax_check_share','id=' + itemId,function(e){
					    				if(!e.success){
					    					alert("该文件不能发布！");
					    				}else{
					    					window.location.href ='/EECloud/index.php/publishres/main?id=' + itemId;
					    				}
					    			},'json');
					    		});

					    		$("#search").click(function(){
					    			var key = $.trim($("#search_value").val());
					    			// alert(content);
					    			var userName = '<?=$userName?>';
					    			// alert(userName);
					    			if(key == ""){
					    				return;
					    			}
					    	
					    			window.location.href = '/EECloud/index.php/ring/search_index?userName='+userName+"&key="+key;
					    		});

					    		$("#search_value").keydown(function(e){
					    			var curkey = e.keyCode;
					    			if(curkey == 13){
					    				$("#search").click();
					    				return false;
					    			}
					    		});

					    	});
						</script>

						